* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5em;
    color: #4a5568;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

header p {
    color: #718096;
    font-size: 1.1em;
}

.input-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.input-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    background: #e2e8f0;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    font-weight: 500;
    -webkit-appearance: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    min-height: 44px;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.tab-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.input-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.input-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#text-input {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.3s ease;
    font-family: inherit;
    -webkit-appearance: none;
    -webkit-border-radius: 15px;
    background-clip: padding-box;
}

#text-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.add-btn {
    margin-top: 15px;
    padding: 12px 30px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    min-height: 44px;
    touch-action: manipulation;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.voice-controls {
    text-align: center;
    margin-bottom: 20px;
}

.voice-record-btn {
    padding: 20px 40px;
    background: linear-gradient(135deg, #ed8936, #dd6b20);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    -webkit-appearance: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    min-height: 44px;
    touch-action: manipulation;
}

.voice-record-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(237, 137, 54, 0.4);
}

.voice-record-btn.recording {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.voice-status {
    color: #718096;
    font-size: 0.9em;
}

.voice-result, .image-result {
    margin-top: 15px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.image-upload {
    text-align: center;
    margin-bottom: 20px;
}

#image-input {
    display: none;
}

.upload-label {
    display: inline-block;
    padding: 20px 40px;
    background: linear-gradient(135deg, #9f7aea, #805ad5);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 500;
    transition: all 0.3s ease;
}

.upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(159, 122, 234, 0.4);
}

.image-preview {
    text-align: center;
    margin: 20px 0;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.homework-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    color: #4a5568;
    font-size: 1.8em;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    background: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.filter-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.filter-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.homework-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    background: #f7fafc;
    padding: 20px;
    border-radius: 15px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.stat-label {
    color: #718096;
    font-size: 0.9em;
}

.homework-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.homework-item {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-left: 5px solid #667eea;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.homework-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.homework-item.completed {
    opacity: 0.7;
    border-left-color: #48bb78;
}

.homework-item.completed .homework-content {
    text-decoration: line-through;
}

.homework-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.homework-subject {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: 500;
}

.homework-priority {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.7em;
    font-weight: 500;
}

.priority-high {
    background: #fed7d7;
    color: #c53030;
}

.priority-medium {
    background: #feebc8;
    color: #dd6b20;
}

.priority-low {
    background: #c6f6d5;
    color: #38a169;
}

.homework-content {
    color: #4a5568;
    font-size: 1.1em;
    line-height: 1.5;
    margin-bottom: 15px;
}

.homework-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.complete-btn {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.complete-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(72, 187, 120, 0.3);
}

.complete-btn.completed {
    background: #e2e8f0;
    color: #718096;
}

.delete-btn {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 10px rgba(229, 62, 62, 0.3);
}

.homework-time {
    color: #a0aec0;
    font-size: 0.8em;
}

.clear-section {
    text-align: center;
}

.clear-btn {
    background: linear-gradient(135deg, #e53e3e, #c53030);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(229, 62, 62, 0.4);
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #a0aec0;
}

.empty-state .emoji {
    font-size: 3em;
    margin-bottom: 15px;
    display: block;
}

/* iOS设备优化 */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    input, textarea, button {
        -webkit-appearance: none;
        border-radius: 0;
    }
}

/* iPad适配 */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
        padding: 30px;
    }
    
    header h1 {
        font-size: 3em;
    }
    
    .input-tabs {
        gap: 15px;
    }
    
    .tab-btn {
        padding: 15px 25px;
        font-size: 18px;
    }
    
    .homework-stats {
        padding: 25px;
    }
    
    .stat-number {
        font-size: 2.5em;
    }
}

/* iPhone适配 */
@media (max-width: 767px) {
    .container {
        padding: 15px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
    }
    
    header {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .input-section {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .filter-buttons {
        justify-content: center;
        gap: 8px;
    }
    
    .filter-btn {
        padding: 10px 15px;
        font-size: 14px;
        min-height: 40px;
    }
    
    .homework-stats {
        flex-direction: row;
        justify-content: space-around;
        padding: 15px;
    }
    
    .homework-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .homework-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .input-tabs {
        flex-direction: column;
        gap: 8px;
    }
    
    .tab-btn {
        padding: 15px;
        font-size: 16px;
    }
    
    .voice-record-btn {
        padding: 15px 30px;
        font-size: 16px;
    }
    
    .upload-label {
        padding: 15px 30px;
        font-size: 16px;
    }
}